
var newsSliderView = function() {
	
	// New window
	var sPanel = Ti.UI.createView();
	
	// Horizontal slider
	var newsArticleSlider = Ti.UI.createScrollableView(S.combine($$.newsArticleSlider,{id:'newsArticleSlider', horizontalBounce:true}));
	
	// Header for Slider Window
	shareBar = Ti.UI.createView(S.combine($$.shareBar));
	
	// Close button
	var sliderCloseButton = Ti.UI.createView(S.combine($$.sliderCloseButton));
	sliderCloseButton.addEventListener('click', function(e) {
		sPanel.close();
	});

	shareBar.add(Ti.UI.createLabel(S.combine({text: 'share/social/search'}, $$.shareBarLabel)));
	shareBar.add(sliderCloseButton);
	
	// man views container
	var views = [];
	
	// Add views to news slider
	views.push(populateNewsStoryPage(json[i], i));
	
	// News slider containing full stories
	newsArticleSlider.views = views;	
	
	// Setting the default view
	newsArticleSlider.scrollToView(index*(1));			


	
	// Top padding
	sPanel.add(Titanium.UI.createLabel(S.combine($$.topPadding)));
				
	// Adding all to the window
	sPanel.add(shareBar);
	sPanel.add(newsArticleSlider);
	
	// Bottom padding
	sPanel.add(Titanium.UI.createLabel(S.combine($$.bottomPadding)));
						
	
						
	/* LISTENERS */	
	sPanel.addEventListener("paginator:update",function(e){

		//Ti.App.fireEvent("app:msg",{msg: "index: " + e.index});

	});
	

	newsArticleSlider.addEventListener("scroll",function(e){
		// Updating the page indicator
		currentPageIndicator.left = paginationItemWidth * newsArticleSlider.currentPage;
	});
					
	sPanel.addEventListener("click",function(e){
		// Showing the share bar on click
		if (S.ui.shareBarIsVisible) {
			Ti.App.fireEvent("app:shareBarShow");
		}
	});						
	
					

	/* Temp
	 * Message view
	 */
	var msgview = Ti.UI.createView({opacity:0,zIndex:10,width:S.ui.properties.platformWidth-100,left:50,top:230,height:100}),
	msglabel = Ti.UI.createLabel($$.Label);
	msgview.add(msglabel);

	Ti.App.addEventListener("app:msg",function(e){
		//Ti.API.log(e);
		msglabel.text = e.msg;
		msgview.backgroundColor = e.error ? "red" : "white";
		msgview.opacity = 1;
		msgview.animate({
			opacity: 0,
			duration: 1500
		});
	});

	sPanel.add(msgview);
	
	
										
	return sPanel;
	
}